import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== $Lazy
const $cache 	= $Lazy.file(()=>import('#private/cache-api'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data: [],
		// 条码作废
		formData:[
			{ label: '开始时间',		name:'start_at', 	type:'date-time',	full:true,	required:true, 	loading:true },
			{ label: '结束时间',		name:'end_at', 		type:'date-time',	full:true,	required:true, 	loading:true },
			{ label: '岗位',		name:'project_id',	type:'select',		full:true, 	required:true,	loading:true },
			{ label: '数量',		name:'num', 		type:'number',		full:true,	required:true,	onValue:({ value, ref }) =>{
				if(value < 1) setTimeout(()=> ref.setValue({ num: 1}) )
			} }
		]
	}
	
	 /* 添加标本批量上架的参数 2021-7-31 --马婷 */
	// 获取下拉数据
	getModalSelect = async () => {
		const { formData } = this.state
		$cache.then( async f => {
			// 岗位
			$fn.setRow( formData, 'project_id', await f.getCache({ api:'gang_wei' }))
			
			this.setState({ formData })
		})
	}
	
	open = ()=> {
		this.getModalSelect()
		this.modal.open({formRef: this.formRef})
	}
	
	render(){
		return FormModal.call(this, {title:'批量上架', labelWidth:'s6', width:700, api:'shelf/fastupshelf',onRefresh:()=> this.props.onRefresh() })
	}
}

export default Index